package com.example.demo.DAO;

import com.example.demo.Entity.Operation;
import com.example.demo.Entity.Statistics;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository()
public interface OperationDao {
    //查询所以操作记录
    @Select("select * from Operation")
    List<Operation> findAllOperation();
    //添加新的操作记录
    @Insert("insert into Operation(userid,statisticsId,type,time,detailed)values(#{userid},#{statisticsId},#{type},#{time},#{detailed})")
    void AddOperation(Operation operation);
    //通过账号 和订单号和 记录的编号进行删除
    @Delete("delete from Operation where id = #{id} and userid = #{userid} and statisticsId = #{statisticsId}")
    Integer DeleteOperation(Operation operation);

    //通过记录的编号进行修改
    @Update("UPDATE Operation SET userid = #{userid},statisticsId = #{statisticsId},type = #{type}" +
            ",time = #{time} where id = #{id}")
    Integer UpdateOperation(Operation operation);

    /******** 模糊查询账务 *********/
    @Select("select * from Operation where concat(id,userid,statisticsId,type,time,detailed) like '%${query}%'")
    List<Operation> QueryOperation(@Param("query") String query);


}
